package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClue;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueMapper;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {
    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;

    @Autowired
    private TbClueMapper tbClueMapper;

    /**
     * 查询线索跟进记录列表
     */
    @Override
    public List<ClueTrackRecordVo> getClueTrackRecord(Long clueId) {
        return tbClueTrackRecordMapper.getClueTrackRecord(clueId);
    }

    /**
     * 添加跟进记录
     */
    @Override
    public void addClueTrackRecord(ClueTrackRecordVo tbClueTrackRecord) {
        //添加线索跟进记录
        tbClueTrackRecord.setCreateBy(SecurityUtils.getUsername());
        tbClueTrackRecord.setCreateTime(DateUtils.getNowDate());
        tbClueTrackRecordMapper.addClueTrackRecord(tbClueTrackRecord);
        //修改   线索表   中，当前线索的状态为：跟进中
        tbClueMapper.updateTbClueStatus(tbClueTrackRecord.getClueId(),"2");
    }
}
